package com.resume.bean;

import com.resume.enums.ResultEnum;

/**
 * 结果工具类
 *
 * @author 梁云亮
 */
public class ResultUtil {

    public static <T> Result<T> success(Integer code, String msg, T data) {
        return new Result<T>().setCode(code).setMsg(msg).setData(data);
    }

    public static <T> Result<T> error(Integer code, String msg, T data) {
        return new Result<T>().setCode(code).setMsg(msg).setData(data);
    }

    public static <T> Result<T> success(String msg, T data) {
        Result<T> res = new Result<T>().setMsg(msg).setData(data);
        return res;
    }

    public static <T> Result<T> error(String msg, T data) {
        Result<T> res = new Result<T>().setMsg(msg).setData(data);
        return res;
    }

    public static <T> Result<T> success(int code, String msg) {
        Result<T> res = new Result<T>().setCode(code).setMsg(msg);
        return res;
    }

    public static <T> Result<T> error(int code, String msg) {
        Result<T> res = new Result<T>().setCode(code).setMsg(msg);
        return res;
    }

    public static <T> Result<T> success(int code, T data) {
        Result<T> res = new Result<T>().setCode(code).setData(data);
        return res;
    }

    public static <T> Result<T> error(int code, T data) {
        return new Result<T>().setCode(code).setData(data);
    }

    public static <T> Result<T> success(ResultEnum resultEnum) {
        Result<T> res = new Result<>(resultEnum);
        return res;
    }

    public static <T> Result<T> error(ResultEnum resultEnum) {
        Result<T> res = new Result<>(resultEnum);
        return res;
    }

    public static void main(String[] args) {
        System.out.println(ResultUtil.success(200, "asdf"));
        System.out.println(ResultUtil.success(200, 1234));
    }
}
